import { Suspense } from "react";
import { Routes, Route, useLocation } from "react-router-dom";
import { routes } from "@/router";
import { Spin } from "antd";
const App = () => {
  const location = useLocation();
  return (
    <Suspense
      fallback={
        <div className="loading">
          <Spin />
        </div>
      }
    >
      <Routes>
        {routes.map((route: any, index: number) => {
          return (
            <Route key={index} path={route.path} element={route.element}>
              {route.children?.map((child: any, i: number) => (
                <Route key={i} path={child.path} element={child.element} />
              ))}
            </Route>
          );
        })}
      </Routes>
    </Suspense>
  );
};

export default App;
